<!DOCTYPE html>
<html>

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="Cache-Control" content="no-siteapp" />

    <title>xmake v2.5.1 发布, 支持 Apple Silicon 并改进 C/C++ 包依赖管理</title>
    <meta name="description" content="xmake 是一个基于 Lua 的轻量级跨平台构建工具，使用 xmake.lua 维护项目构建，相比 makefile/CMakeLists.txt，配置语法更加简洁直观，对新手非常友好，短时间内就能快速入门，能够让用户把更多的精力集中在实际的项目开发上。这是 xmake 在今年的首个版本，也是完全适配支持 Ap...">

    
    <meta name="keywords" content="xmake,lua,C/C++,toolchains,xrepo,packages,vcpkg,conan,Apple,Silicon,tboox" /> 

    <!-- qq oauth -->
    <meta property="qc:admins" content="5211601217706727767255" />

    <!--icon -->
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    <link rel="icon" sizes="192x192" href="/static/img/nice-highres.png" />
	<link rel="apple-touch-icon-precomposed" href="/static/img/apple-touch-icon-57x57-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/static/img/apple-touch-icon-72x72-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/static/img/apple-touch-icon-114x114-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/static/img/apple-touch-icon-144x144-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="180x180" href="/static/img/retinahd_icon.png" />
	<meta name="msapplication-TileImage" content="/static/img/retinahd_icon.png" />
	
    <link rel="stylesheet" href=" /css/fontawesome/css/font-awesome.min.css ">
    <link rel="stylesheet" href=" /css/main.css ">
    <link rel="canonical" href="https://tboox.org/cn/2021/01/16/xmake-update-v2.5.1/">
    <link rel="alternate" type="application/rss+xml" title="TBOOX Open Source Project" href="https://tboox.org/feed.xml ">
    <link rel="alternate" hreflang="en" href="https://tboox.org/" />
    <link rel="alternate" hreflang="zh-Hans" href="https://tboox.org/cn/" />

    <!-- css -->
    <link href="/css/reward.css" rel="stylesheet" type="text/css"> 




    <script type="text/javascript">
    function isPC(){    
        var userAgentInfo = navigator.userAgent;  
        var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");    
        var flag = true;    
        for (var v = 0; v < Agents.length; v++) {    
            if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }    
        }    
        return flag;    
    }
    </script>

<!-- baidu ads -->



    <!-- baidu ads -->

</head>


  <body>

    <header id="top">
    <div class="wrapper">
        <a href="/cn" class="brand">TBOOX</a>
        <button id="headerMenu" class="menu"><i class="fa fa-bars"></i></button>
        <nav id="headerNav">
            <ul>
                <li>
                    
                    <a href="/?lang=0">
                    
                        <i class="fa fa-home"></i>English
                    </a>
                </li>

                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/project/">
                            
                        
                            <i class="fa fa-bookmark"></i>项目
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/archive/">
                            
                        
                            <i class="fa fa-archive"></i>归档
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/category/">
                            
                        
                            <i class="fa fa-th-list"></i>分类
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/tag/">
                            
                        
                            <i class="fa fa-tags"></i>标记
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/docs/">
                            
                        
                            <i class="fa fa-book"></i>文档
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="https://xmake.io/#/zh-cn/about/contact" target="_blank" >
                            
                        
                            <i class="fa fa-forumbee"></i>社区
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/donation/">
                            
                        
                            <i class="fa fa-heart"></i>捐助
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/about/">
                            
                        
                            <i class="fa fa-user"></i>关于
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            </ul>
        </nav>
    </div>
</header>



        <div class="page clearfix" post>
    <div class="left">
        <h1>xmake v2.5.1 发布, 支持 Apple Silicon 并改进 C/C++ 包依赖管理</h1>
        <div class="label">

            <div class="label-card">
                <i class="fa fa-calendar"></i>2021-01-16
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
            


<!-- <span class="point">•</span> -->
<span class="categories">
  <i class="fa fa-th-list"></i>
  
    
        <a href="/category/#xmake" title="Category: xmake" rel="category">xmake</a>
    
  

  <!-- <span class="point">•</span> -->
</span>


            </div>

            <div class="label-card">
            
<!-- <span class="point">•</span> -->
<span class="pageTag">
  <i class="fa fa-tags"></i>
  
    
        <!--a href="/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a-->
        <a href="/cn/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a>&nbsp;
    
        <!--a href="/tag/#lua" title="Tag: lua" rel="tag">lua</a-->
        <a href="/cn/tag/#lua" title="Tag: lua" rel="tag">lua</a>&nbsp;
    
        <!--a href="/tag/#C%2FC%2B%2B" title="Tag: C/C++" rel="tag">C/C++</a-->
        <a href="/cn/tag/#C/C++" title="Tag: C/C++" rel="tag">C/C++</a>&nbsp;
    
        <!--a href="/tag/#toolchains" title="Tag: toolchains" rel="tag">toolchains</a-->
        <a href="/cn/tag/#toolchains" title="Tag: toolchains" rel="tag">toolchains</a>&nbsp;
    
        <!--a href="/tag/#xrepo" title="Tag: xrepo" rel="tag">xrepo</a-->
        <a href="/cn/tag/#xrepo" title="Tag: xrepo" rel="tag">xrepo</a>&nbsp;
    
        <!--a href="/tag/#packages" title="Tag: packages" rel="tag">packages</a-->
        <a href="/cn/tag/#packages" title="Tag: packages" rel="tag">packages</a>&nbsp;
    
        <!--a href="/tag/#vcpkg" title="Tag: vcpkg" rel="tag">vcpkg</a-->
        <a href="/cn/tag/#vcpkg" title="Tag: vcpkg" rel="tag">vcpkg</a>&nbsp;
    
        <!--a href="/tag/#conan" title="Tag: conan" rel="tag">conan</a-->
        <a href="/cn/tag/#conan" title="Tag: conan" rel="tag">conan</a>&nbsp;
    
        <!--a href="/tag/#Apple" title="Tag: Apple" rel="tag">Apple</a-->
        <a href="/cn/tag/#Apple" title="Tag: Apple" rel="tag">Apple</a>&nbsp;
    
        <!--a href="/tag/#Silicon" title="Tag: Silicon" rel="tag">Silicon</a-->
        <a href="/cn/tag/#Silicon" title="Tag: Silicon" rel="tag">Silicon</a>
    
  

</span>

            </div>

        </div>
        <hr>
        <article itemscope itemtype="http://schema.org/BlogPosting">
        <p><a href="https://github.com/xmake-io/xmake">xmake</a> 是一个基于 Lua 的轻量级跨平台构建工具，使用 xmake.lua 维护项目构建，相比 makefile/CMakeLists.txt，配置语法更加简洁直观，对新手非常友好，短时间内就能快速入门，能够让用户把更多的精力集中在实际的项目开发上。</p>

<p>这是 xmake 在今年的首个版本，也是完全适配支持 Apple Silicon (macOS ARM) 设备的首个版本。</p>

<p>这个版本，我们主要改进了对 C/C++ 依赖包的集成支持，更加的稳定，并且能够更加灵活的实现定制化配置编译。</p>

<p>另外，我们还重点改进 vs/vsxmake 两个vs工程生成器插件，修复了很多细节问题，并且对子工程<code class="highlighter-rouge">分组</code>也做了支持，现在可以生成类似下图的工程结构。</p>

<p><img src="https://xmake.io/assets/img/manual/set_group.png" alt="" /></p>

<p>关于 Zig 方面，0.7.1 版本修复了很多我之前反馈的问题，现在 xmake 也已经可以很好的支持对 zig 项目的编译。</p>

<p>同时，我们还新开发了一个 <a href="https://github.com/xmake-io/luarocks-build-xmake">luarocks=build-xmake</a> 插件去用 xmake 替换 luarocks 内置的构建系统。</p>

<p>最后，在这个版本中，我们继续改进了 <code class="highlighter-rouge">xmake f --menu</code> 图形化配置菜单，完全支持鼠标操作和滚动支持，也对 utf8 做了支持。</p>

<ul>
  <li><a href="https://github.com/xmake-io/xmake">项目源码</a></li>
  <li><a href="https://xmake.io/#/zh-cn/">官方文档</a></li>
  <li><a href="https://xmake.io/#/zh-cn/about/course">入门课程</a></li>
</ul>

<h2 id="新特性介绍">新特性介绍</h2>

<h3 id="新增-add_requireconfs-改进包配置">新增 add_requireconfs 改进包配置</h3>

<p>尽管之前的版本，我们可以通过 <code class="highlighter-rouge">add_requires("libpng", {configs = {shared = true}})</code> 的方式来定义和配置依赖包。</p>

<p>但是，如果用户项目的工程庞大，依赖包非常多，且每个包都需要不同的编译配置参数，那么配置起来还是会非常繁琐，并且具有局限性，比如无法改写内部的子依赖包配置。</p>

<p>因此，我们新增了 <code class="highlighter-rouge">add_requireconfs</code> 去更灵活方便的配置每个包的配置以及它的子依赖，下面我们重点介绍几种用法：</p>

<h5 id="扩充指定包的配置">扩充指定包的配置</h5>

<p>这是基本用法，比如我们已经通过 <code class="highlighter-rouge">add_requires("zlib")</code> 声明了一个包，想要在后面对这个 zlib 的配置进行扩展，改成动态库编译，可以通过下面的方式配置。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"zlib"</span><span class="p">)</span>
<span class="n">add_requireconfs</span><span class="p">(</span><span class="s2">"zlib"</span><span class="p">,</span> <span class="p">{</span><span class="n">configs</span> <span class="o">=</span> <span class="p">{</span><span class="n">shared</span> <span class="o">=</span> <span class="kc">true</span><span class="p">}})</span>
</code></pre>
</div>

<p>它等价于</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"zlib"</span><span class="p">,</span> <span class="p">{</span><span class="n">configs</span> <span class="o">=</span> <span class="p">{</span><span class="n">shared</span> <span class="o">=</span> <span class="kc">true</span><span class="p">}})</span>
</code></pre>
</div>

<h5 id="设置通用的默认配置">设置通用的默认配置</h5>

<p>上面的用法，我们还看不出有什么实际用处，但如果依赖多了就能看出效果了，比如下面这样：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"zlib"</span><span class="p">,</span> <span class="p">{</span><span class="n">configs</span> <span class="o">=</span> <span class="p">{</span><span class="n">shared</span> <span class="o">=</span> <span class="kc">true</span><span class="p">}})</span>
<span class="n">add_requires</span><span class="p">(</span><span class="s2">"pcre"</span><span class="p">,</span> <span class="p">{</span><span class="n">configs</span> <span class="o">=</span> <span class="p">{</span><span class="n">shared</span> <span class="o">=</span> <span class="kc">true</span><span class="p">}})</span>
<span class="n">add_requires</span><span class="p">(</span><span class="s2">"libpng"</span><span class="p">,</span> <span class="p">{</span><span class="n">configs</span> <span class="o">=</span> <span class="p">{</span><span class="n">shared</span> <span class="o">=</span> <span class="kc">true</span><span class="p">}})</span>
<span class="n">add_requires</span><span class="p">(</span><span class="s2">"libwebp"</span><span class="p">,</span> <span class="p">{</span><span class="n">configs</span> <span class="o">=</span> <span class="p">{</span><span class="n">shared</span> <span class="o">=</span> <span class="kc">true</span><span class="p">}})</span>
<span class="n">add_requires</span><span class="p">(</span><span class="s2">"libcurl"</span><span class="p">,</span> <span class="p">{</span><span class="n">configs</span> <span class="o">=</span> <span class="p">{</span><span class="n">shared</span> <span class="o">=</span> <span class="kc">false</span><span class="p">}})</span>
</code></pre>
</div>

<p>是不是非常繁琐，如果我们用上 <code class="highlighter-rouge">add_requireconfs</code> 来设置默认配置，就可以极大的简化成下面的配置：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requireconfs</span><span class="p">(</span><span class="s2">"*"</span><span class="p">,</span> <span class="p">{</span><span class="n">configs</span> <span class="o">=</span> <span class="p">{</span><span class="n">shared</span> <span class="o">=</span> <span class="kc">true</span><span class="p">}})</span>
<span class="n">add_requires</span><span class="p">(</span><span class="s2">"zlib"</span><span class="p">)</span>
<span class="n">add_requires</span><span class="p">(</span><span class="s2">"pcre"</span><span class="p">)</span>
<span class="n">add_requires</span><span class="p">(</span><span class="s2">"libpng"</span><span class="p">)</span>
<span class="n">add_requires</span><span class="p">(</span><span class="s2">"libwebp"</span><span class="p">)</span>
<span class="n">add_requires</span><span class="p">(</span><span class="s2">"libcurl"</span><span class="p">,</span> <span class="p">{</span><span class="n">configs</span> <span class="o">=</span> <span class="p">{</span><span class="n">shared</span> <span class="o">=</span> <span class="kc">false</span><span class="p">}})</span>
</code></pre>
</div>

<p>上面的配置，我们通过 <code class="highlighter-rouge">add_requireconfs("*", {configs = {shared = true}})</code> 使用模式匹配的方式，设置所有的依赖包默认走动态库编译安装。</p>

<p>但是，我们又通过 <code class="highlighter-rouge">add_requires("libcurl", {configs = {shared = false}})</code> 将 libcurl 进行了特殊配置，强制走静态库编译安装。</p>

<p>最终的配置结果为：zlib/pcre/libpng/libwebp 是 shared 库，libcurl 是静态库。</p>

<p>我们通过模式匹配的方式，可以将一些每个包的常用配置都放置到统一的 <code class="highlighter-rouge">add_requireconfs</code> 中去预先配置好，极大简化每个 <code class="highlighter-rouge">add_requires</code> 的定义。</p>

<p>!&gt; 默认情况下，对于相同的配置，xmake 会优先使用 add_requires 中的配置，而不是 add_requireconfs。</p>

<p>如果 <code class="highlighter-rouge">add_requires("zlib 1.2.11")</code> 中设置了版本，就会优先使用 add_requires 的配置，完全忽略 add_requireconfs 里面的版本配置，当然我们也可以通过 override 来完全重写 <code class="highlighter-rouge">add_requires</code> 中指定的版本。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"zlib 1.2.11"</span><span class="p">)</span>
<span class="n">add_requireconfs</span><span class="p">(</span><span class="s2">"zlib"</span><span class="p">,</span> <span class="p">{</span><span class="n">override</span> <span class="o">=</span> <span class="kc">true</span><span class="p">,</span> <span class="n">version</span> <span class="o">=</span> <span class="s2">"1.2.10"</span><span class="p">})</span>
</code></pre>
</div>

<h5 id="改写包依赖配置">改写包依赖配置</h5>

<p>其实 <code class="highlighter-rouge">add_requireconfs</code> 最大的用处是可以让用户改写安装包的特定依赖包的配置。</p>

<p>什么意思呢，比如我们项目中集成使用 libpng 这个包，并且使用了动态库版本，但是 libpng 内部依赖的 zlib 库其实还是静态库版本。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"libpng"</span><span class="p">,</span> <span class="p">{</span><span class="n">configs</span> <span class="o">=</span> <span class="p">{</span><span class="n">shared</span> <span class="o">=</span> <span class="kc">true</span><span class="p">}})</span>
</code></pre>
</div>

<p>那如果我们想让 libpng 依赖的 zlib 包也改成动态库编译，应该怎么配置呢？这就需要 <code class="highlighter-rouge">add_requireconfs</code> 了。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"libpng"</span><span class="p">,</span> <span class="p">{</span><span class="n">configs</span> <span class="o">=</span> <span class="p">{</span><span class="n">shared</span> <span class="o">=</span> <span class="kc">true</span><span class="p">}})</span>
<span class="n">add_requireconfs</span><span class="p">(</span><span class="s2">"libpng.zlib"</span><span class="p">,</span> <span class="p">{</span><span class="n">configs</span> <span class="o">=</span> <span class="p">{</span><span class="n">shared</span> <span class="o">=</span> <span class="kc">true</span><span class="p">}})</span>
</code></pre>
</div>

<p>通过 <code class="highlighter-rouge">libpng.zlib</code> 依赖路径的写法，指定内部某个依赖，改写内部依赖配置。</p>

<p>如果依赖路径很深，比如 <code class="highlighter-rouge">foo -&gt; bar -&gt; xyz</code> 的依赖链，我们可以写成：<code class="highlighter-rouge">foo.bar.xyz</code></p>

<p>我们也可以改写 libpng 依赖的内部 zlib 库版本：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"libpng"</span><span class="p">)</span>
<span class="n">add_requireconfs</span><span class="p">(</span><span class="s2">"libpng.zlib"</span><span class="p">,</span> <span class="p">{</span><span class="n">version</span> <span class="o">=</span> <span class="s2">"1.2.10"</span><span class="p">})</span>
</code></pre>
</div>

<h5 id="级联依赖的模式匹配">级联依赖的模式匹配</h5>

<p>如果一个包的依赖非常多，且依赖层次也很深，怎么办呢，比如 libwebp 这个包，它的依赖有：</p>

<div class="highlighter-rouge"><pre class="highlight"><code>libwebp
  - libpng
    - zlib
    - cmake
  - libjpeg
  - libtiff
    - zlib
  - giflib
  - cmake
</code></pre>
</div>

<p>如果我想改写 libwebp 里面的所有的依赖库都加上特定配置，那么挨个配置，就会非常繁琐，这个时候就需要 <code class="highlighter-rouge">add_requireconfs()</code> 的递归依赖模式匹配来支持了。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"libwebp"</span><span class="p">)</span>
<span class="n">add_requireconfs</span><span class="p">(</span><span class="s2">"libwebp.**|cmake"</span><span class="p">,</span> <span class="p">{</span><span class="n">configs</span> <span class="o">=</span> <span class="p">{</span><span class="n">cxflags</span> <span class="o">=</span> <span class="s2">"-DTEST"</span><span class="p">}})</span>
</code></pre>
</div>

<p>上面的配置，我们将 libwebp 中所以的库依赖就额外加上了 <code class="highlighter-rouge">-DTEST</code> 来编译，但是 cmake 依赖属于构建工具依赖，我们可以通过 <code class="highlighter-rouge">|xxx</code> 的方式排除它。</p>

<p>这里的模式匹配写法，与 <code class="highlighter-rouge">add_files()</code> 非常类似。</p>

<p>我们在给几个例子，比如这回我们只改写 libwebp 下单级的依赖配置，启用调试库：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"libwebp"</span><span class="p">)</span>
<span class="n">add_requireconfs</span><span class="p">(</span><span class="s2">"libwebp.*|cmake"</span><span class="p">,</span> <span class="p">{</span><span class="n">debug</span> <span class="o">=</span> <span class="kc">true</span><span class="p">})</span>
</code></pre>
</div>

<h3 id="图形化配置支持鼠标和滚动操作">图形化配置支持鼠标和滚动操作</h3>

<p>我们升级了 xmake 所使用的 tui 组件库：<a href="https://github.com/tboox/ltui">LTUI</a>，增加了对鼠标的支持，以及部分组件的滚动支持，我们可以再图形化配置中，更加灵活方便的配置编译选项。</p>

<p><img src="https://tboox.org/static/img/ltui/choicebox_scrollbar.png" width="650px" /></p>

<h3 id="stdin-重定向输入支持">stdin 重定向输入支持</h3>

<p>之前的版本中，xmake 提供的 os.execv/os.runv 等进程执行接口，仅仅只支持 stdout/stderr 输出重定向，但是并不支持 stdin 输入重定向，因此在这个版本中，我们对其也做了支持。</p>

<p>使用方式如下：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">os</span><span class="p">.</span><span class="n">execv</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"arg1"</span><span class="p">,</span> <span class="s2">"arg2"</span><span class="p">},</span> <span class="p">{</span><span class="n">stdin</span> <span class="o">=</span> <span class="s2">"/tmp/a"</span><span class="p">})</span>
</code></pre>
</div>

<p>我们可以执行进程的时候，将 /tmp/a 文件作为重定向输入，当然我们还可以传递 <code class="highlighter-rouge"><span class="p">{</span><span class="err">stdout</span><span class="w"> </span><span class="err">=</span><span class="w"> </span><span class="nt">"/tmp/out"</span><span class="err">}</span></code> 等作为重定向输出。</p>

<h3 id="vs-工程分组支持">vs 工程分组支持</h3>

<p>我们新增了一个接口 <code class="highlighter-rouge">set_group</code>，来对每个 target 进行分组支持，此接口目前仅用于 vs/vsxmake 工程生成，对 vs 工程内部子工程目录树按指定结构分组展示，不过后续也可能对其他模块增加分组支持。</p>

<p>比如对于下面的分组配置：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_rules</span><span class="p">(</span><span class="s2">"mode.debug"</span><span class="p">,</span> <span class="s2">"mode.release"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test1"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.cpp"</span><span class="p">)</span>
    <span class="n">set_group</span><span class="p">(</span><span class="s2">"group1"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test2"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.cpp"</span><span class="p">)</span>
    <span class="n">set_group</span><span class="p">(</span><span class="s2">"group1"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test3"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.cpp"</span><span class="p">)</span>
    <span class="n">set_group</span><span class="p">(</span><span class="s2">"group1/group2"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test4"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.cpp"</span><span class="p">)</span>
    <span class="n">set_group</span><span class="p">(</span><span class="s2">"group3/group4"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test5"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.cpp"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test6"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.cpp"</span><span class="p">)</span>
</code></pre>
</div>

<p>生成的 vs 工程目录结构效果如下：</p>

<p><img src="https://xmake.io/assets/img/manual/set_group.png" alt="" /></p>

<p>其中 <code class="highlighter-rouge">set_group("group1/group2")</code> 可以将 target 设置到二级分组中去。</p>

<h3 id="vs-工程自动更新规则">vs 工程自动更新规则</h3>

<p>如果觉得每次通过 <code class="highlighter-rouge">xmake project -k vsxmake</code> 命令来生成和更新 vs 工程很繁琐，我们现在可以通过在 xmake.lua 中配置 <code class="highlighter-rouge">plugin.vsxmake.autoupdate</code> 规则来实现自动更新。</p>

<p>用户可以在 vs 工程中每次执行构建后，如果文件列表或者 xmake.lua 有改动，vs 工程都会自动更新。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_rules</span><span class="p">(</span><span class="s2">"plugin.vsxmake.autoupdate"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">)</span>
</code></pre>
</div>

<h3 id="vsvsxmake-工程插件改进">vs/vsxmake 工程插件改进</h3>

<p>除了上面提到的分组支持和自动更新，这个版本中，我们还修复了不少 vs 工程相关的问题，比如：intellisense 提示改进，路径被截断的问题修复，全面支持远程依赖包</p>

<h3 id="改进-windows-注册表支持">改进 windows 注册表支持</h3>

<p>xmake 改进了内部的 winos 模块，新增了一些接口来更加方便的访问注册表，获取 windows 上的注册表配置。</p>

<h4 id="winosregistry_keys">winos.registry_keys</h4>

<ul>
  <li>获取注册表建列表</li>
</ul>

<p>支持通过模式匹配的方式，遍历获取注册表键路径列表，<code class="highlighter-rouge">*</code> 为单级路径匹配，<code class="highlighter-rouge">**</code> 为递归路径匹配。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="kd">local</span> <span class="n">keypaths</span> <span class="o">=</span> <span class="n">winos</span><span class="p">.</span><span class="n">registry_keys</span><span class="p">(</span><span class="s2">"HKEY_LOCAL_MACHINE\\SOFTWARE\\*\\Windows NT\\*\\CurrentVersion\\AeDebug"</span><span class="p">)</span>
<span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">keypath</span> <span class="k">in</span> <span class="nb">ipairs</span><span class="p">(</span><span class="n">keypaths</span><span class="p">)</span> <span class="k">do</span>
    <span class="nb">print</span><span class="p">(</span><span class="n">winos</span><span class="p">.</span><span class="n">registry_query</span><span class="p">(</span><span class="n">keypath</span> <span class="o">..</span> <span class="s2">";Debugger"</span><span class="p">))</span>
<span class="k">end</span>
</code></pre>
</div>

<h4 id="winosregistry_values">winos.registry_values</h4>

<ul>
  <li>获取注册表值名列表</li>
</ul>

<p>支持通过模式匹配的方式，获取指定键路径的值名列表，<code class="highlighter-rouge">;</code> 之后的就是指定的键名模式匹配字符串。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="kd">local</span> <span class="n">valuepaths</span> <span class="o">=</span> <span class="n">winos</span><span class="p">.</span><span class="n">registry_values</span><span class="p">(</span><span class="s2">"HKEY_LOCAL_MACHINE\\SOFTWARE\\xx\\AeDebug;Debug*"</span><span class="p">)</span>
<span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">valuepath</span> <span class="k">in</span> <span class="nb">ipairs</span><span class="p">(</span><span class="n">valuepaths</span><span class="p">)</span> <span class="k">do</span>
    <span class="nb">print</span><span class="p">(</span><span class="n">winos</span><span class="p">.</span><span class="n">registry_query</span><span class="p">(</span><span class="n">valuepath</span><span class="p">))</span>
<span class="k">end</span>
</code></pre>
</div>

<h4 id="winosregistry_query">winos.registry_query</h4>

<ul>
  <li>获取注册表建值</li>
</ul>

<p>获取指定注册表建路径下的值，如果没有指定值名，那么获取键路径默认值</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="kd">local</span> <span class="n">value</span><span class="p">,</span> <span class="n">errors</span> <span class="o">=</span> <span class="n">winos</span><span class="p">.</span><span class="n">registry_query</span><span class="p">(</span><span class="s2">"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug"</span><span class="p">)</span>
<span class="kd">local</span> <span class="n">value</span><span class="p">,</span> <span class="n">errors</span> <span class="o">=</span> <span class="n">winos</span><span class="p">.</span><span class="n">registry_query</span><span class="p">(</span><span class="s2">"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug;Debugger"</span><span class="p">)</span>
</code></pre>
</div>

<h3 id="zig-项目构建支持">Zig 项目构建支持</h3>

<p>在上个版本中，xmake 已经对 zig 进行了实验性支持，但是期间也躺了不少坑，尤其是 windows/macos 上构建中遇到了不少问题。</p>

<p>然后在最新的 zig 0.7.1 中，已经将我遇到的大部分问题都修复了，现在 xmake 已经可以很好的支持 zig 项目编译。</p>

<p>我们可以通过下面的命令，快速创建一个 Zig 空工程：</p>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>xmake create -l zig console
</code></pre>
</div>

<p>xmake.lua 内容如下：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_rules</span><span class="p">(</span><span class="s2">"mode.debug"</span><span class="p">,</span> <span class="s2">"mode.release"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"console"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.zig"</span><span class="p">)</span>
</code></pre>
</div>

<p>可以看到，其实配置方式跟 C/C++ 并没有什么不同，由于 Zig 和 C 有很好的二进制兼容，因此我们也可以使用 <code class="highlighter-rouge">add_requires</code> 来给 zig 项目添加 C/C++ 包的远程依赖支持。</p>

<p>然后执行 xmake 就可以完成编译了。</p>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>xmake
</code></pre>
</div>

<p>然后继续运行 run 命令，就可以直接执行 zig 程序，输出运行结果。</p>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>xmake run
Hello world!
</code></pre>
</div>

<p>我们还可以很方便的实现 C 和 Zig 的混合编译支持，只需要添加上对应的 C 代码文件就可以了。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_rules</span><span class="p">(</span><span class="s2">"mode.debug"</span><span class="p">,</span> <span class="s2">"mode.release"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"console"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.zig"</span><span class="p">,</span> <span class="s2">"src/*.c"</span><span class="p">)</span>
</code></pre>
</div>

<p>完整代码例子见：<a href="https://github.com/xmake-io/xmake/blob/dev/tests/projects/zig/console_c_call_zig/xmake.lua">Zig with C</a></p>

<h3 id="luarocks-插件">Luarocks 插件</h3>

<p><a href="https://luarocks.org/">luarocks</a> 是 lua 的一个包管理工具，提供了各种 lua 模块的安装集成，不过它本身在对 lua c 模块进行构建是采用的内建的构建机制。</p>

<p>比如在它的 rockspec 文件中通过 builtin 构建类型来描述常用 lua c 模块的构建：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">build</span> <span class="o">=</span> <span class="p">{</span>
    <span class="nb">type</span> <span class="o">=</span> <span class="s2">"builtin"</span><span class="p">,</span>
    <span class="n">modules</span> <span class="o">=</span> <span class="p">{</span>
        <span class="p">[</span><span class="s2">"module.hello"</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span>
            <span class="n">sources</span> <span class="o">=</span> <span class="s2">"src/test.c"</span>
        <span class="p">}</span>
    <span class="p">},</span>
    <span class="n">copy_directories</span> <span class="o">=</span> <span class="p">{}</span>
<span class="p">}</span>
</code></pre>
</div>

<p>这对于小模块而言，并没有什么问题，但如果模块的 c 代码结构比较复杂，它内置的构建规则还是有很多的局限性，并不灵活，另外切换 msvc / mingw 工具链以及参数配置什么的都不够灵活。</p>

<p>因此，xmake 提供了 <a href="https://github.com/xmake-io/luarocks-build-xmake">luarocks=build-xmake</a> 插件去替换 luarocks 内置的构建系统，替换方式也很简单，只需要将 builtin 构建类型改成 xmake，并加上 luarocks-build-xmake 依赖就行了。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">dependencies</span> <span class="o">=</span> <span class="p">{</span>
    <span class="s2">"lua &gt;= 5.1"</span><span class="p">,</span>
    <span class="s2">"luarocks-build-xmake"</span>
<span class="p">}</span>
<span class="n">build</span> <span class="o">=</span> <span class="p">{</span>
    <span class="nb">type</span> <span class="o">=</span> <span class="s2">"xmake"</span><span class="p">,</span>
    <span class="n">modules</span> <span class="o">=</span> <span class="p">{</span>
        <span class="p">[</span><span class="s2">"module.hello"</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span>
            <span class="n">sources</span> <span class="o">=</span> <span class="s2">"src/test.c"</span>
        <span class="p">}</span>
    <span class="p">},</span>
    <span class="n">copy_directories</span> <span class="o">=</span> <span class="p">{}</span>
<span class="p">}</span>
</code></pre>
</div>

<p>但是这样还是很繁琐，还是要基于 rockspec 文件中 modules 中的源文件列表来描述规则，然后 luarocks-build-xmake 会自动根据配置生成 xmake.lua 来完成构建。</p>

<p>不过既然用了 xmake，那么自己的 lua 模块，完全可以用 xmake.lua 来维护，这样构建配置就更加灵活了，因此我们只需要下面这样就行了。</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">dependencies</span> <span class="o">=</span> <span class="p">{</span>
    <span class="s2">"lua &gt;= 5.1"</span><span class="p">,</span>
    <span class="s2">"luarocks-build-xmake"</span>
<span class="p">}</span>
<span class="n">build</span> <span class="o">=</span> <span class="p">{</span>
    <span class="nb">type</span> <span class="o">=</span> <span class="s2">"xmake"</span><span class="p">,</span>
    <span class="n">copy_directories</span> <span class="o">=</span> <span class="p">{}</span>
<span class="p">}</span>
</code></pre>
</div>

<p>只需要设置当前切换到 xmake 编译，完全使用 lua 模块项目内置的 xmake.lua 规则文件。</p>

<h3 id="支持在-windows-安装部署-qt-程序">支持在 windows 安装部署 Qt 程序</h3>

<p>非常感谢 @SirLynix 的贡献，xmake 已经可以支持在 windows 上部署安装 Qt 应用程序。</p>

<p>我们只需要正常维护一个 Qt 程序，例如：</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_rules</span><span class="p">(</span><span class="s2">"mode.debug"</span><span class="p">,</span> <span class="s2">"mode.release"</span><span class="p">)</span>

<span class="n">target</span><span class="p">(</span><span class="s2">"demo"</span><span class="p">)</span>
    <span class="n">add_rules</span><span class="p">(</span><span class="s2">"qt.quickapp"</span><span class="p">)</span>
    <span class="n">add_headerfiles</span><span class="p">(</span><span class="s2">"src/*.h"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.cpp"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/qml.qrc"</span><span class="p">)</span>
</code></pre>
</div>

<p>然后，我们只需要执行下面的编译安装命令，xmake 就会自动调用 windeployqt.exe 程序去安装部署我们的 Qt 应用。</p>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>xmake
<span class="gp">$ </span>xmake install -o d:<span class="se">\i</span>nstalldir
</code></pre>
</div>

<p>相关补丁：<a href="https://github.com/xmake-io/xmake/pull/1145">#1145</a></p>

<p>另外，在之前的版本中，xmake 也已经支持对 macOS 和 android 版本的 Qt 程序进行部署打包，每次只需要正常的编译命令，就可以生成 QT .app/.apk 安装包。</p>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>xmake f -p android --ndk<span class="o">=</span>/xxx/android-ndk-r20b --sdk<span class="o">=</span>/xxx
<span class="gp">$ </span>xmake
</code></pre>
</div>

<h3 id="一些问题修复">一些问题修复</h3>

<p>我们还修复了不少用户反馈的问题，这里我们介绍一些比较重要的 bug 修复，例如：</p>

<p>我们修复了 <code class="highlighter-rouge">add_defines("TEST=\"hello world\"")</code> 中内部带有空的双引号问题，之前编译会出错。</p>

<p>另外我们改进了 vstudio 环境的查找和支持，解决了用户 home 目录和环境变量中带有中文导致的编译失败问题。</p>

<p>我们也改进了 llvm 工具链，解决了 macOS 下如果没有安装 xcode 的情况下，使用 llvm 工具链缺少 isysroot 配置问题，以及 msvc 下头文件依赖编译偶尔失效问题。</p>

<h2 id="更新内容">更新内容</h2>

<h3 id="新特性">新特性</h3>

<ul>
  <li><a href="https://github.com/xmake-io/xmake/issues/1035">#1035</a>: 图形配置菜单完整支持鼠标事件，并且新增滚动栏</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1098">#1098</a>: 支持传递 stdin 到 os.execv 进行输入重定向</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1079">#1079</a>: 为 vsxmake 插件添加工程自动更新插件，<code class="highlighter-rouge">add_rules("plugin.vsxmake.autoupdate")</code></li>
  <li>添加 <code class="highlighter-rouge">xmake f --vs_runtime=MT</code> 和 <code class="highlighter-rouge">set_runtimes("MT")</code> 去更方便的对 target 和 package 进行设置</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1032">#1032</a>: 支持枚举注册表 keys 和 values</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1026">#1026</a>: 支持对 vs/vsmake 工程增加分组设置</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1178">#1178</a>: 添加 <code class="highlighter-rouge">add_requireconfs()</code> 接口去重写依赖包的配置</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1043">#1043</a>: 为 luarocks 模块添加 <code class="highlighter-rouge">luarocks.module</code> 构建规则</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1190">#1190</a>: 添加对 Apple Silicon (macOS ARM) 设备的支持</li>
  <li><a href="https://github.com/xmake-io/xmake/pull/1145">#1145</a>: 支持在 windows 上安装部署 Qt 程序, 感谢 @SirLynix</li>
</ul>

<h3 id="改进">改进</h3>

<ul>
  <li><a href="https://github.com/xmake-io/xmake/issues/1072">#1072</a>: 修复并改进 cl 编译器头文件依赖信息</li>
  <li>针对 ui 模块和 <code class="highlighter-rouge">xmake f --menu</code> 增加 utf8 支持</li>
  <li>改进 zig 语言在 macOS 上的支持</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1135">#1135</a>: 针对特定 target 改进多平台多工具链同时配置支持</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1153">#1153</a>: 改进 llvm 工具链，针对 macos 上编译增加 isysroot 支持</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1071">#1071</a>: 改进 vs/vsxmake 生成插件去支持远程依赖包</li>
  <li>改进 vs/vsxmake 工程生成插件去支持全局的 <code class="highlighter-rouge">set_arch()</code> 设置</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1164">#1164</a>: 改进 vsxmake 插件调试加载 console 程序</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1179">#1179</a>: 改进 llvm 工具链，添加 isysroot</li>
</ul>

<h3 id="bugs-修复">Bugs 修复</h3>

<ul>
  <li><a href="https://github.com/xmake-io/xmake/issues/1091">#1091</a>: 修复不正确的继承链接依赖</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1105">#1105</a>: 修复 vsxmake 插件 c++ 语言标准智能提示错误</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1132">#1132</a>: 修复 vsxmake 插件中配置路径被截断问题</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1142">#1142</a>: 修复安装包的时候，出现git找不到问题</li>
  <li>修复在 macOS Big Sur 上 macos.version 问题</li>
  <li><a href="https://github.com/xmake-io/xmake/issues/1084">#1084</a>: 修复 <code class="highlighter-rouge">add_defines()</code> 中带有双引号和空格导致无法正确处理宏定义的问题</li>
  <li><a href="https://github.com/xmake-io/xmake/pull/1195">#1195</a>: 修复 unicode 编码问题，改进 vs 环境查找和进程执行</li>
</ul>

        </article>
        <hr>

        <!-- baidu ads -->
        

        <!-- reward -->
        <div style="text-align: center;">
            <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
              <span>赏</span>
            </button>
            <div id="QR" style="display: none;">
                <div id="wechat" style="display: inline-block">
                  <img id="wechat_qr" src="/static/img/weixin.png" alt="WeChat Pay"/>
                  <p>微信打赏</p>
                </div>
                <div id="alipay" style="display: inline-block">
                  <img id="alipay_qr" src="/static/img/alipay.png" alt="Alipay"/>
                  <p>支付宝打赏</p>
                </div>
            </div>
        </div>

        
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
                    
                    <h2 id="english">English</h2>
                    <ul>
                    
                    <li class="relatedPost">
                        <a href="/2021/01/16/xmake-update-v2.5.1/">xmake v2.5.1 released, Support for Apple Silicon and more powerful C/C++ package management
                        
                        </a>
                    </li>
                    
                    
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
        
            </ul>
        

        
        
            
        
            
            
            
                
                    
                        
                        <h2 id="similar_posts">相关文章</h2>
                        <ul>
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/12/17/xmake-update-v2.6.2/">xmake v2.6.2 发布，新增 Linux 内核驱动模块构建支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/12/03/xmake-update-v2.6.1/">xmake v2.6.1 发布，使用 Lua5.4 运行时，Rust 和 C++ 混合编译支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/10/30/xmake-update-v2.5.9/">xmake v2.5.9 发布，改进 C++20 模块，并支持 Nim, Keil MDK 和 Unity Build
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/10/08/xmake-update-v2.5.8/">xmake v2.5.8 发布，新增 Pascal/Swig 程序和 Lua53 运行时支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/08/29/xmake-update-v2.5.7/">xmake v2.5.7 发布，包依赖锁定和 Vala/Metal 语言编译支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
        
            </ul>
        

        <div class="post-recent">
    <div class="pre">

        

        

        
        
        <p><strong>上一篇</strong> <a href="/cn/2020/12/30/xmake-in-2020/">Xmake 2020 年终总结</a></p>
        
    </div>

    <div class="nex">

        

        

        
        
        

        

        

        
        
        <p><strong>下一篇</strong> <a href="/cn/2021/01/22/luarocks-build-xmake-v1.0/">一个使用 xmake 构建 c/c++ 模块的 luarocks 插件</a></p>
        
    </div>
</div>


        <h2 id="comments">评论</h2>
        






<div id="gitalk-container"></div>
<link rel="stylesheet" href="/css/gitalk.css">
<script src="/js/gitalk.min.js"></script>

<script>
const gitalk = new Gitalk({
  clientID: '73946dc1d9e2276ad0da',
  clientSecret: '12a3cb94361ba3ebc6ecb68cf80d592bfaa8106d',
  repo: 'tboox.github.io',
  owner: 'waruqi',
  admin: ['waruqi'],
  id: location.pathname,       
  language: 'zh-CN',
  distractionFreeMode: false  
})

gitalk.render('gitalk-container')
</script>





    </div>
    <button class="anchor"><i class="fa fa-anchor"></i></button>
    <div class="right">
        <div class="wrap">

            <!-- codefund ads -->
            

            <!-- Content -->
            <div class="side content">
                <div>
                    内容
                </div>
                <ul id="content-side" class="content-ul">
                    <li><a href="#english">English</a></li>
                    <li><a href="#similar_posts">相关文章</a></li>
                    <li><a href="#comments">评论</a></li>
                </ul>
            </div>


            <!-- baidu ads -->
            
            
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    链接
                </div>
                <ul class="content-ul">
                  <li><a href="http://github.com/waruqi/tbox">tbox</a></li>
                  <li><a href="http://www.xmake.io">xmake</a></li>
                  <li><a href="https://github.com/waruqi">github</a></li>
                </ul>
            </div> 

            <!-- xmake courses -->
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    xmake 入门课程
                </div>
                <a href="https://xmake.io/#/zh-cn/about/course" target="_blank">
                <img src="/static/img/xmake-course.png" alt="course" width="256" height="193">
                </a>
            </div>

            <!-- qqgroup -->
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    技术交流群（QQ）
                </div>
                <img src="/static/img/qqgroup.png" alt="qqgroup" width="256" height="284">
            </div> 

            <!-- google ads -->
            

            <!-- baidu ads -->
            

        </div>
    </div>

    <!-- baidu ads -->
    
</div>
<script>
/**
 * target _blank
 */
(function() {
    var aTags = document.querySelectorAll('article a:not([id])')
    for (var i = 0; i < aTags.length; i++) {
        aTags[i].setAttribute('target', '_blank')
    }
}());
</script>
<script src="/js/pageContent.js " charset="utf-8"></script>



    <footer class="site-footer">
    <div class="wrapper">
        <p class="description">
             Copyright (c) 2016-2020 tboox.org 
        </p>
        <p class="contact">
            
            <a href="https://github.com/waruqi" title="GitHub"><i class="fa fa-github" aria-hidden="true"></i></a> 
             
            
            <a href="mailto:waruqi@gmail.com" title="email"><i class="fa fa-envelope-o" aria-hidden="true"></i></a> 
            
            
            <a href="https://twitter.com/waruqi" title="Twitter"><i class="fa fa-twitter" aria-hidden="true"></i></a> 
            
            <a href="/feed.xml" title="feed"><i class="fa fa-feed" aria-hidden="true"></i></a> 
        </p>
        <p class="power">
            <span>
                Site powered by <a href="https://jekyllrb.com/">Jekyll</a> & <a href="https://github.com/Gaohaoyang">HyG</a> & <a href="https://pages.github.com/">Github Pages</a>.
            </span>
        </p>
    </div>
</footer>

    <div class="back-to-top">
    <a href="#top" class="scroll">
        <i class="fa fa-arrow-up" aria-hidden="true"></i>
    </a>
</div>

    <script src=" /js/main.js " charset="utf-8"></script>
    <script src=" /js/scroll.min.js " charset="utf-8"></script>
  </body>

</html>
